use shq_common::prelude::get_my_pool;
use sqlx::Row;
use super::SubmitType;

pub async fn action_check_example(run_id: u64,
    _step_id: u8,
    action_type: SubmitType) -> anyhow::Result<bool> {
    match action_type {
        SubmitType::SendNext => {
            let sql = "select acid from comp_acco_divi_flow_new WHERE frid=?";
            let row = sqlx::query(&sql)
                .bind(&run_id)
                .fetch_one(get_my_pool())
                .await?;
            let acid: Option<u64> = row.try_get(0)?;
            if acid.is_none() {
                return Err(anyhow::anyhow!("no acid"));
            }
            Ok(true)
        },
        SubmitType::SendBack => Ok(true),
        SubmitType::Suspend => Ok(true),
        SubmitType::TakeBack => Ok(true),
        SubmitType::Activate => Ok(true),
        SubmitType::Completed => Ok(true),
    }
}
